package cn.silver.module.quartz.domain;

import cn.silver.framework.core.utils.DateUtils;
import cn.silver.framework.mybatis.annotation.Table;
import cn.silver.framework.mybatis.annotation.TableField;
import cn.silver.framework.mybatis.domain.BaseEntity;
import cn.silver.framework.mybatis.enums.SearchTypeEnums;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import java.util.Date;

/**
 * 定时任务调度日志表 sys_job_log
 *
 * @author hb
 */
@Data
@NoArgsConstructor
@Table(name = "sys_job_log")
@EqualsAndHashCode(callSuper = true)
@Schema(name = "SysJobLog", description = "定时任务调度日志表")
public class SysJobLog extends BaseEntity {
    private static final long serialVersionUID = 1L;
    @Schema(title = "任务名称")
    @TableField(name = "job_id", searchType = SearchTypeEnums.EQ)
    private String jobId;

    /**
     * 任务名称
     */
    @Schema(title = "任务名称")
    @TableField(name = "job_name", searchType = SearchTypeEnums.LIKE)
    private String jobName;

    /**
     * 任务组名
     */
    @Schema(title = "任务组名")
    @TableField(name = "job_group", searchType = SearchTypeEnums.EQ)
    private String jobGroup;

    /**
     * 调用目标字符串
     */
    @Schema(title = "调用目标字符串")
    private String invokeTarget;

    /**
     * 日志信息
     */
    @Schema(title = "日志信息")
    private String jobMessage;

    /**
     * 执行状态（0正常 1失败）
     */
    @Schema(title = "执行状态（0正常 1失败）")
    @TableField(name = "status", searchType = SearchTypeEnums.EQ)
    private String status;

    /**
     * 异常信息
     */
    @Schema(title = "异常信息")
    private String exceptionInfo;

    /**
     * 开始时间
     */
    @Schema(title = "开始时间")
    @TableField(name = "start_time", searchType = SearchTypeEnums.BETWEEN)
    @JsonFormat(timezone = DateUtils.TIME_ZONE, pattern = DateUtils.YYYY_MM_DD_HH_MM_SS)
    private Date startTime;

    /**
     * 停止时间
     */
    @Schema(title = "停止时间")
    @JsonFormat(timezone = DateUtils.TIME_ZONE, pattern = DateUtils.YYYY_MM_DD_HH_MM_SS)
    private Date stopTime;

    @Override
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
                .append("jobLogId", getId())
                .append("jobName", getJobName())
                .append("jobGroup", getJobGroup())
                .append("jobMessage", getJobMessage())
                .append("status", getStatus())
                .append("exceptionInfo", getExceptionInfo())
                .append("startTime", getStartTime())
                .append("stopTime", getStopTime())
                .toString();
    }
}
